﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight;
using PocketBook.UI.ViewModel.Contents;
using System.Windows;
using System.Windows.Media;
using PocketBook.UI.View;
using PocketBook.UI.ViewModel.Dialogs;

namespace PocketBook.UI.ViewModel.Workspaces
{
    public class FileWorkspaceViewModel : WorkspaceViewModel
    {
        private MainWindowViewModel _parent;

        #region Constructor

        public FileWorkspaceViewModel(MainWindowViewModel parent)
        {
            base.DisplayName = "File";
            _parent = parent;
            this.CreateMenu();

        }

        #endregion

        #region FileMenu

        private List<FileMenuViewModel> _fileMenu;
        public List<FileMenuViewModel> FileMenu
        {
            get
            {
                return _fileMenu;
            }
            set
            {
                _fileMenu = value;
            }
        }

        #endregion

        #region PrivateHelpers

        private void CreateMenu()
        {
            FileMenu = new List<FileMenuViewModel> 
            {
                new FileMenuViewModel("New income", _parent.IncomesWorkspace.AddIncomeCommand),
                new FileMenuViewModel("New expense", _parent.ExpensesWorkspace.AddExpenseCommand),
                new FileMenuViewModel("About", new RelayCommand(( ) => this.OpenAboutWindow())),
                new FileMenuViewModel("Exit", _parent.CloseCommand)
            };
        }

        private void OpenAboutWindow()
        {
            var win = new PocketBookDialog();
            win.DataContext = new AboutDialogViewModel(win);
            win.Title = "Pocket Book - About";
            win.ShowDialog();
        }

        #endregion
    }
}
